//////////////////////////////////////////////////////////////////////////
#pragma once
#pragma managed
//////////////////////////////////////////////////////////////////////////
NAMESPACE_BEGIN
//////////////////////////////////////////////////////////////////////////
class auto_string
{
public:
	auto_string(System::String^ str) { ptrStr = Marshal::StringToHGlobalAnsi(str);}
	~auto_string() { Marshal::FreeHGlobal(ptrStr); }
	operator const char*() { return (char*)ptrStr.ToPointer(); }
private:
	IntPtr ptrStr;
};

#define PROPERTY_READONLY(TYPE, NAME, CVTYPE, MEMBER)													\
	property TYPE NAME { TYPE get() { return (TYPE)(((CVTYPE*)m_pHandle)->MEMBER); } } 

#define PROPERTY_READONLY_PTR(NAME, CVTYPE, MEMBER)														\
	property IntPtr NAME { IntPtr get() { return IntPtr((void*)(((CVTYPE*)m_pHandle)->MEMBER)); } } 

#define PROPERTY_READONLY_NATIVE_HANDLE(TYPE, NAME, CVTYPE, MEMBER)										\
	property TYPE##^ NAME { TYPE##^ get() { return gcnew TYPE(((CVTYPE*)m_pHandle)->MEMBER); } } 

#define PROPERTY_READONLY_NATIVE_HANDLE_EX(TYPE, NAME, CVTYPE, MEMBER, OWN)								\
	property TYPE##^ NAME { TYPE##^ get() { return gcnew TYPE(((CVTYPE*)m_pHandle)->MEMBER, OWN); } } 

#define PROPERTY_WRITEONLY(TYPE, NAME, CVTYPE, MEMBER, MEMBERTYPE)										\
	property TYPE NAME { void set(TYPE value) { ((CVTYPE*)m_pHandle)->MEMBER) = (MEMBERTYPE)value; } } 

#define PROPERTY_READWRITE(TYPE, NAME, CVTYPE, MEMBER, MEMBERTYPE)										\
	property TYPE NAME {																				\
	TYPE get() { return (TYPE)(((CVTYPE*)m_pHandle)->MEMBER); }											\
	void set(TYPE value) { ((CVTYPE*)m_pHandle)->MEMBER) = (MEMBERTYPE)value; } } 


//////////////////////////////////////////////////////////////////////////
NAMESPACE_END
//////////////////////////////////////////////////////////////////////////